<template>
  <div class="movie">
    <div class="title">
      <span>即将上映的电视</span>
    </div>
    <div class="item">
      <div class="list" v-for="(item, index) in showList" :key="index">
        <div class="imgUrl">
          <img :src="item.cover_url" alt="" />
        </div>
        <span class="subtitle">{{ item.title }}</span>
        <span class="pinfen">评分:{{ item.score }}</span>
      </div>
    </div>

    <div class="title">
      <span>热映电视剧</span>
    </div>
    <div class="item">
      <div class="list" v-for="(item, index) in showList2" :key="index">
        <div class="imgUrl">
          <img :src="item.cover_url" alt="" />
        </div>
        <span class="subtitle">{{ item.title }}</span>
        <span class="pinfen">评分:{{ item.score }}</span>
      </div>
    </div>

    <!-- 热映电视剧 -->
    <div class="title">
      <span>热映电视剧</span>
    </div>
    <div class="item">
      <div class="list" v-for="item in showList">
        <div class="imgUrl">
          <img :src="item.cover_url" alt="" />
        </div>
        <span class="subtitle">{{ item.title }}</span>
        <span class="pinfen">评分:{{ item.score }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showList: [],
      showList2: [],
    };
  },
  created() {
    setTimeout(() => {
       this.show(); 
    }, 700);
    
  },
  methods: {
    async show() {
      this.$axios
        .get("http://localhost:8080/data/broadcast.json")
        .then((res) => {
          if (res.status == 200) {
            this.showList = res.data.recommend_one;
            this.showList2 = res.data.recommend_two;
          }
        });
    },
  },
};
</script>

<style lang="less" scoped>
.movie {
  width: 100vw;
  .title {
    padding: 15px;
    font-weight: 600;
    color: rgb(108, 105, 105);
  }
  .item {
    display: flex;
    overflow-y: hidden;

    .list {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin: 0 10px 15px 10px;
      border-bottom: 1px solid #ccc;
      .imgUrl {
        width: 100px;
        margin: 0 -10px 5px 0;
        img {
          height: 150px;
          width: 100px;
        }
      }
      .subtitle {
        overflow: hidden;
        flex-wrap: nowrap;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        height: 33px;
        display: -webkit-box;
      }
      .pinfen {
        height: 30px;
        font-size: 13px;
        color: #666;
        line-height: 20px;
      }
    }
  }
}
</style>